package com.treeroot.controller;

import com.treeroot.entity.MessageEntity;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class ProducerController {
    @Resource
    private AmqpTemplate amqpTemplate;

    @GetMapping("/send")
    public String send() {
        /**
         * 交换机名称
         * 路由key
         * 发送内容
         */

        amqpTemplate.convertAndSend("/sp-rabbit", "", new MessageEntity("1", "2", "189", "136"));

        return "发送成功";
    }
}

